﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

namespace H_GAME
{
    public class Cls_Stage
    {

        private int _stage;
        public int Stage
        {
            get { return _stage; }
            set { _stage = value; }
        }

        //背景
        private Bitmap _imgback;
        public Bitmap Imgback
        {
            get { return _imgback; }
            set { _imgback = value; }
        }

        //背景2
        private Bitmap _imgback2;
        public Bitmap Imgback2
        {
            get { return _imgback2; }
            set { _imgback2 = value; }
        }

        //背景3
        private Bitmap _imgback3;
        public Bitmap Imgback3
        {
            get { return _imgback3; }
            set { _imgback3 = value; }
        }

        /// <summary>
        /// 背景音乐
        /// </summary>
        private string musicpath;
        public string Musicpath
        {
            get { return musicpath; }
            set { musicpath = value; }
        }

        public int delay = 0;

        /// <summary>
        /// 获取缩小后的图片
        /// </summary>
        /// <param name="bm">要缩小的图片</param>
        /// <param name="times">要缩小的倍数</param>
        /// <returns></returns>
        private Bitmap GetSmallPic(Bitmap bm, double times)
        {
            int nowWidth = (int)(bm.Width / times);
            int nowHeight = (int)(bm.Height / times);
            Bitmap newbm = new Bitmap(nowWidth, nowHeight);//新建一个放大后大小的图片

            if (times >= 1 && times <= 1.1)
            {
                newbm = bm;
            }
            else
            {
                Graphics g = Graphics.FromImage(newbm);
                //g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                //g.SmoothingMode = SmoothingMode.HighQuality;
                //g.CompositingQuality = CompositingQuality.HighQuality;
                g.DrawImage(bm, new Rectangle(0, 0, nowWidth, nowHeight), new Rectangle(0, 0, bm.Width, bm.Height), GraphicsUnit.Pixel);
                g.Dispose();
            }
            return newbm;
        }

        /// <summary>
        /// 合适图片
        /// </summary>
        /// <param name="bm">要缩小的图片</param>
        /// <param name="times">要缩小的倍数</param>
        /// <returns></returns>
        public Bitmap GetFixPic(int picboxWidth, int picboxHeight)
        {
           

            Bitmap newbm = new Bitmap(picboxWidth, Imgback.Height);//新建一个放大后大小的图片
            Graphics g = Graphics.FromImage(newbm);
            //g.InterpolationMode = InterpolationMode.HighQualityBicubic;
          //  g.SmoothingMode = SmoothingMode.HighQuality;
           // g.CompositingQuality = CompositingQuality.HighQuality;
            g.DrawImage(Imgback2, new Rectangle(0, 0, picboxWidth, picboxHeight), new Rectangle(0, 0, Imgback.Width, Imgback.Height), GraphicsUnit.Pixel);
            //背景动画
            if (delay < Imgback3.Width)
            {
                Rectangle HeadNew = new Rectangle(delay, 0, Imgback3.Width, Imgback3.Height);
                g.DrawImage(Imgback3, 0, 0, HeadNew, GraphicsUnit.Pixel);
                Rectangle HeadNew2 = new Rectangle(0, 0, delay * 10, Imgback3.Height);
                g.DrawImage(Imgback3, Imgback3.Width - delay, 0, HeadNew2, GraphicsUnit.Pixel);
                delay = delay+10;
            }
            else
            {
                Rectangle HeadNew = new Rectangle(0, 0, Imgback3.Height, Imgback3.Height);
                g.DrawImage(Imgback3, 0, 0, HeadNew, GraphicsUnit.Pixel);
                delay = 0;
            }
            g.DrawImage(Imgback, new Rectangle(0, 0, picboxWidth, picboxHeight), new Rectangle(0, 0, Imgback.Width, Imgback.Height), GraphicsUnit.Pixel);
            g.Dispose();
            return newbm;
        }
    }
}
